#include "pw_pbl/Coroutine.hpp"
#include <iostream>

thread_local pw_pbl::Coroutine<>::DefaultExecutor<5> exec;

void pw_pbl::Coroutine<>::await_suspend(pw_pbl::Coroutine<>::Awaitor fr)
{
	exec.await_suspend(std::move(fr));
}

static auto codi = 0;

pw_pbl::Coroutine<int> sod(void)
{
	codi++;
	co_await []
	{ return codi > 3; };
	codi++;
	co_await []
	{ return codi > 6; };
	codi++;
	co_return 0;
}

pw_pbl::Coroutine<int> ado()
{
	co_await pw_pbl::Coroutine<>::Any(sod(), []
									  { return codi; });
	co_return codi;
}

int main(void)
{
	auto a = ado();
	while (!exec.run())
		codi++;
	return a.result();
}
